import unittest
from api.GoodsAPI import Goods
from api.GropBuy import CreateGroupBuy


class TestCreateGroupBuy(unittest.TestCase):
    def setUp( self ):
        self.CreateGroupBuy = CreateGroupBuy()
        self.Goods = Goods()

    # 创建团购
    def test_post_add_goods( self ):
        goods_no = self.Goods.get_goods_list().json()["data"][0]["goodsNo"]
        goods_name = self.Goods.get_goods_list().json()["data"][0]["name"]
        goods_weight = self.Goods.get_goods_list().json()["data"][0]["weight"]
        goods_price = self.Goods.get_goods_list().json()["data"][0]["price"]
        response = self.CreateGroupBuy.post_create_group_buy("测试22111",0,1,10,goods_no,goods_name,goods_weight,0.01)
        # 断言
        print(response.text)
        self.assertEqual("成功", response.json().get("msg"))

if __name__ == '__main__':
    unittest.main()